<template>
  <div class="content">
    <!--汇率类型列表弹窗-->
    <el-dialog
      v-dialogDrag
      title="汇率类型"
      model
      :visible.sync="isCurrencyDialog"
      :close-on-click-modal="false"
      width="60%"
      :before-close="handleClose"
    >
      <jc-table
        :table-data="currencyDialogData"
        :table-header="currencyDialogHeader"
        table-height="53vh"
        serial
        @clickRow="currencySelectRow"
      />
      <jc-pagination
        v-show="currency.total > 0"
        :total="currency.total"
        :page.sync="currency.pageNum"
        :limit.sync="currency.pageSize"
        @pagination="queryRateType"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryExchangeRateList } from '@/api/basicManagement/currencyRates'

export default {
  data() {
    return {
      // 汇率类型
      isCurrencyDialog: true,
      currency: {
        fgroupId: 0,
        total: 0, // 总条目
        pageNum: 1, // 当前页
        pageSize: 200 // 每页显示多少条数据
      },
      currencyDialogData: [],
      currencyDialogHeader: [
        { label: this.$t('market.groupname'), prop: 'fgroupName' },
        { label: this.$t('market.fromcurr'), prop: 'fromcurrName' },
        { label: this.$t('market.tocurr'), prop: 'tocurrName' },
        { label: this.$t('market.exchangerate'), prop: 'exchangerate' },
        { label: this.$t('market.contraryrate'), prop: 'contraryrate' },
        { label: this.$t('market.effectiveDate'), prop: 'starttime' },
        { label: this.$t('market.endData'), prop: 'endtime' }
      ],
      prodValue: { fsettleCurrIdName: '', fsettleCurrId: '', isCurrencyDialog: true }
    }
  },
  created() {
    this.queryRateType()
  },
  methods: {
    // 查询汇率类型
    async queryRateType() {
      this.isCurrencyDialog = true
      const DATA = this.currency
      const { data: RES } = await queryExchangeRateList(DATA)
      this.currencyDialogData = RES.list
      this.currency.total = RES.total
    },
    currencySearch() {
      this.currency.pageNum = 1
      this.queryRateType()
    },
    // 选择汇率类型
    currencySelectRow(item) {
      this.$emit('rates', item)
    },
    // 关闭前回调
    handleClose() {
      this.prodValue.isCurrencyDialog = false
      this.$emit('rates', this.prodValue)
    }
  }
}
</script>
<style scoped lang="scss">
.content {
  @include listBom;
}
</style>

